package com.tree.service.impl;

import com.tree.dao.RtreeDao;
import com.tree.entity.Rtree;
import com.tree.service.RtreeService;
import com.tree.util.PageCal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RtreeServiceImpl implements RtreeService {

    @Autowired
    private RtreeDao rtreeDao;
    @Override
    public Rtree query(String treeName) {
        Rtree rtree = rtreeDao.query(treeName);
        if (rtree != null && rtree.getlName() != null)
            return rtree;
        return null;
    }

    @Override
    public List<Rtree> queryAll(int pageIndex, int rowSize) {

        //将页数转换为行数
        int rowIndex = PageCal.calculateRowIndex(pageIndex,rowSize);
        return rtreeDao.queryAll(rowIndex,rowSize);
    }

    @Override
    public List<Rtree> querySearch(String treeName) {
        return rtreeDao.querySearch(treeName);
    }
}
